﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class SkillInfoWindowManager : MonoBehaviour
{

    public static SkillInfoWindowManager _instance;
    public ushort SkillID = 10000;

    /// <summary>
    /// 技能图标
    /// </summary>
    public Image SkillIcon;
    /// <summary>
    /// 技能名称
    /// </summary>
    public Text SkillName;
    /// <summary>
    /// 技能描述
    /// </summary>
    public Text SkillDes;

    public Sprite DefSprite;
    
	// Use this for initialization
	void Awake ()
	{
	    _instance = this;
	    DefSprite = SkillIcon.sprite;
	}

    /// <summary>
    /// 设置技能信息
    /// </summary>
    /// <param name="info"></param>
    public void SetSkillInfo(ushort SkillID)
    {
        this.SkillID = SkillID;
        //获取图标信息类
        SkillIconInfo info = MatchManager._instance.GetSkillInfo(SkillID);
        //获取图标
        SkillIcon.sprite = IconSpriteManager._instance.GetSkillIconFromIndex(SkillID);
        //获取技能名
        SkillName.text = info.SkillName;
        //获取技能描述
        SkillDes.text = info.SkillDesc;
    }

    public void ResetSkillInfo()
    {
        SkillID = 10000;
        SkillIcon.sprite = DefSprite;
        SkillName.text = "";
        SkillDes.text = "";
    }

    /// <summary>
    /// 取当前选择的技能发送给服务器，并且重置当前选择
    /// </summary>
    /// <returns></returns>
    public ushort GetSkillIDToServer()
    {
        ushort SkillIDToServer = SkillID;
        ResetSkillInfo();
        return SkillIDToServer;
    }
}
